function setcookie (name, value, the_time) 
{
	var expDate = new Date();
	expDate.setTime (expDate.getTime() + (the_time * 1000));
	document.cookie = name + "=" + escape (value) + "; expires=" + expDate.toGMTString ();
}

function show_hide(id)
{
	if ($(id).style.display != 'none') 
	{ 
		Effect.SlideUp(id);
	}
	else
	{ 
		Effect.SlideDown(id);
	}
}


function show_hidden_comm (id)
{
	$('hidden_l'+id).style.display = 'none';
	$('hidden_c'+id).style.display = 'block';
	return false;
}


function add_art_rating (the_id, the_value)
{
	new Ajax.Updater('rating_' + the_id, '/blog/ajax/post_vote/', 
		{
			parameters: { 
							id: the_id,
							value: the_value							
						}
		});
}

function add_com_rating (the_id, the_value)
{
	new Ajax.Updater('comm_rating_' + the_id, '/blog/ajax/comm_vote/', 
		{
			parameters: { 
							id: the_id,
							value: the_value							
						}
		});
}

function add_answer (the_id, module, idi)
{
	var the_form = "<form name='answer' id='answer_form_" + the_id + 
		"' action='' onsubmit=\"update_comments('" + module + "', " + the_id +", " + idi + "); return false;\" method=post>" +
		"<input type=hidden name=parent value='" + the_id + "'><textarea name=com_body rows=2 style='width:90%'></textarea>"+
		"<br><input type=button value='скрыть' onclick=\"add_answer( " + the_id +",'" + module + "', " + idi + ")\"> "+
		"<input type=submit value='добавить'></form>";
		
		var the_element = $('answer_' + the_id);
		if (the_element.style.display == "none") 
		{
			if (the_element.innerHTML == '')
				the_element.innerHTML = the_form;
				
			Effect.SlideDown(the_element);
			document.answer.com_body.focus();
		}
		else 
		{
			Effect.SlideUp(the_element);
			//the_element.innerHTML = '';
		}
}

function update_comments (module, the_id, idi)
{
	new Ajax.Updater('comments_div', '/blog/ajax/comm_update/', 
		{
			parameters: { 
							id: idi,
							parent: the_id,
							module: module,														
							com_body: $("answer_form_" + the_id).com_body.value				
						}
		});
}

function reload_captcha () 
{
	var rndval = new Date().getTime(); 
	$('captcha_image').innerHTML = "<img src='/image.php?mod=bot&rnd=" + rndval + "' align='absmiddle' />";
}

function add_friend (the_id)
{
	new Ajax.Updater('friends_list_false', '/user/ajax/add_friend/', 
		{
			parameters: { 
							id: the_id
						}
		});
}

function change_karma (the_id, value)
{
	new Ajax.Updater('karma_value', '/user/ajax/karma_vote/', 
		{
			parameters: { 
							user_id: the_id,
							value: value							
						}
		});
}

function vote_blog_karma (value, the_id)
{
	setcookie ("blog_" + the_id, "1", 36000);
	
	new Ajax.Updater('karma_value', '/blog/ajax/blog_vote/', 
	{
		parameters: { 
						blog_name: the_id,
						value: value							
					}
	});
}

function blog (the_id, type)
{
	// lost
	new Ajax.Updater('blog_options', '/blog/ajax/blog_join/', 
	{
		parameters: { 
						blog_id: the_id,
						type: type 
					}
	});
}

function show_reg_form () 
{
	$('reg_form').style.display = "block";
	$('screen').style.display = "block";
}

function close_reg_form () 
{
	$('reg_form').style.display = "none";
	$('screen').style.display = "none";
}


//$(document).ready(function () 
//{
/*	$("#logo").corner("10px tl tr");
	$("#menu").corner("10px bl br");
	$("#footer").corner("10px");
	$("#main_table").corner("10px");
	$("#user_karma").corner("10px");
	$(".block").corner("10px tl bl");
	//$(".blog_info").corner("10px");
	$(".site_message").corner("8px");
	$(".site_error").corner("8px");
	$("#second_navigation li").corner("8px tl tr");
	$("#second_navigation").corner("8px bl br");
	$("#block_last_user_arts").corner("10px");
	$("#block_users_top").corner("10px");*/	
//});

function close_answer (the_id) 
{
	$('#answer_'+the_id).slideUp('slow');
}
